Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Openapi property based testing #172

Merged
merged 7 commits into from
Jun 22, 2020
Merged

Conversation

leszke
Copy link
Contributor

@leszke leszke commented Jun 16, 2020

This PR introduces property-based approach to APIv3 testing, with a little help of StreamData framework. I also incorporated the fix/enhancement of 'the hack of the hack' introduced in #168. Shortly speaking, the request containing, from the needed fields, only data, alert/body and alert/title fields, was matched against SilentNotification schema, what has been leading to improper Unexpected field: alert error.

I also improved ControllersHelper.missing_field_response helper function to better reflect possible error messages we can encounter during tests, basing on the API version being used.


# basic types
defp nonempty_string() do
StreamData.string(:alphanumeric) |> StreamData.filter(fn x -> String.length(x) > 0 end)
Copy link
Contributor

@NelsonVides NelsonVides Jun 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about something like (or whatever the correct syntax is)

Suggested change
StreamData.string(:alphanumeric) |> StreamData.filter(fn x -> String.length(x) > 0 end)
StreamData.string(:alphanumeric, min_length: 1)

Note that StreamData.string/2 can take the same options than list_of/1.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch 😀

@DenysGonchar
Copy link

looks good. please recheck Nelson's suggestion.

@NelsonVides NelsonVides force-pushed the openapi-property-based-testing branch from b8988fd to bba7d83 Compare June 19, 2020 16:42
Copy link
Contributor

@NelsonVides NelsonVides left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! 😄

@NelsonVides NelsonVides merged commit 39fe6ef into master Jun 22, 2020
@NelsonVides NelsonVides deleted the openapi-property-based-testing branch June 22, 2020 10:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants